import time

from hytest import STEP, INFO, CHECK_POINT, GSTORE
from lib.share import *

class UI_C1001:
    ddt_cases = [
        {'name': 'UI-C1001', 'para': {'a': '2022-07-04', 'b': ''}},
        {'name': 'UI-C1002', 'para': {'a': '2099-01-04', 'b': ''}},
        {'name': 'UI-C1003', 'para': {'a': '', 'b': '2022-07-04'}},
        {'name': 'UI-C1004', 'para': {'a': '', 'b': '2002-07-04'}},
        {'name': 'UI-C1005', 'para': {'a': '2022-07-01', 'b': '2022-07-31'}},
        {'name': 'UI-C1006', 'para': {'a': '2022-07-06', 'b': '2022-07-10'}},
        {'name': 'UI-C1007', 'para': {'a': '2022-07-03', 'b': '2022-06-07'}},
        {'name': 'UI-C3002', 'para': {'a': '', 'b': '2016-05-13'}},

    ]

    def teststeps(self):
        # obj1 = GSTORE['thome']
        # obj2 = GSTORE['thomework_create']
        # obj3 = GSTORE['iframe_homework_create']
        # obj4 = GSTORE['thomework_created']
        # obj5 = GSTORE['question_info']
        # obj6 = GSTORE['release_to_student']
        obj7 = GSTORE['release']

        after = self.para['a']
        before = self.para['b']
        if after:
            obj7.input(obj7.loc_after, after)
        if before:
            obj7.input(obj7.loc_before, before)
        obj7.click(obj7.loc_search)

        obj7.driver.implicitly_wait(1)
        homework_count = len(obj7.locates(obj7.loc_released_homework))
        obj7.driver.implicitly_wait(5)

        INFO(homework_count)
        if self.name in ['UI-C1001','UI-C1003','UI-C1005']:
            CHECK_POINT('筛选出目标作业', homework_count > 0)
        if self.name in ['UI-C1002','UI-C1004','UI-C1006','UI-C1007']:
            CHECK_POINT('未筛选出目标作业', homework_count == 0)
        if self.name == 'UI-C3002':
            obj7.click_floor(xpath,obj7.loc_delete_value,index1=1)
            obj7.click(obj7.loc_delete_submit)
            check_txt = obj7.get_txt(obj7.loc_delete_lose_txt)
            obj7.click(obj7.loc_delect_lose)
            CHECK_POINT('撤销失败，提示”错误 : 该任务已经有学生做了，不能再撤销“',
                        check_txt == '错误 : 该任务已经有学生做了，不能再撤销')

        obj7.clear(obj7.loc_after)
        obj7.clear(obj7.loc_before)
        obj7.click(obj7.loc_search)

class UI_C2001:
    name = 'UI-C2001'

    def teardown(self):
        GSTORE['thome'].open_homework_released()

    def teststeps(self):
        # obj1 = GSTORE['thome']
        # obj2 = GSTORE['thomework_create']
        # obj3 = GSTORE['iframe_homework_create']
        # obj4 = GSTORE['thomework_created']
        # obj5 = GSTORE['question_info']
        # obj6 = GSTORE['release_to_student']
        obj7 = GSTORE['release']

        obj7.click_floor(xpath,obj7.loc_complate_info_value,index1=1)
        check_txt = obj7.get_txt(obj7.loc_check_txt_student)
        CHECK_POINT('进入详细任务界面',check_txt=='学生')